<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" href="../../../common/js/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="footer.css" />
		<link rel="stylesheet" href="../../css/lystyle.css" />
		<link rel="stylesheet" href="../../css/backstage.css" />
		<style type="text/css">
			/*修改底部字体颜色*/
			
			.foot:nth-child(2) {
				color: #e83023;
			}
			
			.ly-line {
				margin: 5px 0.69444rem;
				height: 1px;
				background: #DEDEDE;
			}
		</style>
		<script src="../../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<div id="wrap">
			<div id="main">
				<div id="header">
					<a id="headImg" href="javascript:history.go(-1)"><img class="headImg" src="../../images/12.png" /></a>

					<!--<a class="ly-headright" id="fo_app" data-toggle="modal" data-target="#myModal">冻结申请</a>	-->
					<p id="headTitle">提现</p>
				</div>

				<div class="row">
					<form action="" method="post">
						<div class="col-xs-5 col-sm-5" style="margin: 5px;">
							<select id="status" class="form-control ly_select">
								<option value="">全部</option>
								<option value="1">提现成功</option>
								<option value="-1">提现失败</option>
								<option value="0">提现中</option>
								= </select>
						</div>
						<div class="col-xs-5 col-sm-5" style="margin: 5px;">
							<select id="statusT" class="form-control ly_select">
								<option value="2017-7">2017年7月</option>
								<option value="2017-10">按本月统计</option>
								<option value="2017-10">本月统计中</option>
								<option value="2017-10">按时间段</option>
							</select>
						</div>
					</form>
				</div>
				<!--内容-->
				<div id="content">
					<!--全部-->
					<div class="ly-info">
						<ul class="ly-info-ul">

						</ul>
					</div>
				</div>
			</div>
		</div>
		<!-- 按钮触发模态框 -->
		<!-- 模态框（Modal） -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h5 style="text-align: center;color:#e83023;" class="modal-title" id="myModalLabel">冻结理由</h5>
					</div>
					<div class="modal-body">
						<textarea rows="7" id="buapSpare1" style="background: #F8F8F8;width: 100%;border-color: #EDEDED;" placeholder="请输入冻结理由"></textarea>
					</div>
					<div class="modal-footer" style="text-align: center;">
						<button type="button" class="btn btn-danger" data-dismiss="modal">取消</button>
						<button id="submit" type="button" class="btn btn-danger">确定</button>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal -->
		</div>

	</body>
	<script type="text/javascript" src="../../js/jquery-2.2.3.min.js"></script>
	<script type="text/javascript" src="../../../common/js/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	<script src="../../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var tokenReztApp = $.cookie("tokenReztApp");
		if(!tokenReztApp) {
			window.location.href = "../login/login/login.html";
		}
		$(function() {
			currentyf();
		});

		//用户信息
		var user, role, goodsId;
		//获取当前会员信息
		function currentyf() {
			$.ajax({
				cache: false,
				type: "GET",
				url: "http://47.104.13.109/member-service/auth/current?token=" + tokenReztApp,
				dataType: "JSON",
				async: false,
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					$.removeCookie('tokenReztApp', {
						expires: 7,
						path: '/'
					});
					$.removeCookie("tokenRh", {
						expires: 7,
						path: '/'
					});
					$.removeCookie('memberId', {
						expires: 7,
						path: '/'
					});
					$.removeCookie('roleId', {
						expires: 7,
						path: '/'
					});
					window.location.href = "../login/login/login.html";
				},
				success: function(data) {
					var check = false;
					for(var i = 0; i < data.roleList.length; i++) {
						var role = data.roleList[i].id;
						var deadline = new Date(data.roleList[i].deadline);
						if(role == "f1" && deadline >= new Date()) {
							check = true;
						}
						if(role == "f2" && deadline >= new Date()) {
							check = true;
						}
					}
					if(!check) {
						window.location.href = "../login/login/login.html";
					}
					user = data.loginName;
					role = data.roleList[0].id; //角色
					goodsId = data.id;

				}
			});
		}
		$(document).ready(function() {
			var userName = '';
			var pageNum = '1';
			var pageSize = '1000';
			var auditStatus = null;
			var startTime = $("#statusT").val();
			var endTime = $("#statusT").val();

			function cash(stu) {
				$.ajax({
					type: "get",
					url: "http://47.104.13.109/member-service/member/mine/member?token=" + tokenReztApp,
					async: false,
					success: function(data) {

					}
				});
				$.ajax({
					type: "get",
					url: "http://47.104.13.109/applyfor-service/drawmoney/search",
					async: true,
					data: {
						pageNum: pageNum,
						pageSize: pageSize,
						applyforUser: user,
					},
					success: function(data) {
						console.log(data);
						if(data.code == 0) {
							return console.log(data.message);
						}
						var list = data.applyformsList.list;
						var a = 0;
						for(var i = 0; i < list.length; i++) {
							var status = "提现成功";
							var statusCss = 'ly-success';
							a = list[i].auditStatus;
							if(a == 0) {
								status = "提现中";
								statusCss = 'ly-continue';
							} else if(a == 1) {
								status = "提现成功";
								statusCss = 'ly-success';
							} else if(a == -1) {
								status = "提现失败";
								statusCss = 'ly-error';
							}
							if(stu == '') {
								$(".ly-info-ul").append('<li class="ly-info-li padding-tb"><p class="ly-font16">提现金额：<span>' + list[i].money + '</span><span class="' + statusCss + '">' + status + '</span></p><p class="ly-font14">' + list[i].applyforDate + '</p></li>')
							} else if(stu == a) {
								$(".ly-info-ul").append('<li class="ly-info-li padding-tb"><p class="ly-font16">提现金额：<span>' + list[i].money + '</span><span class="' + statusCss + '">' + status + '</span></p><p class="ly-font14">' + list[i].applyforDate + '</p></li>')
							}

						}

					}
				});

			}
			cash('');
			console.log(userName)
			$("#status").change(function() {
				$(".ly-info-ul").html('');
				cash($("#status").val());
			})
			$("#statusT").change(function() {
				startTime = $("#statusT").val();
				endTime = $("#statusT").val();
				$(".ly-info-ul").html('');
				cash();
			})

			$("#submit").click(function() {
				if($("#buapSpare1").val() == '') {
					alert("请输入冻结理由");
					return
				}
				$.ajax({
					type: "get",
					url: "http://47.104.13.109/member-service/auth/current?token=" + $.cookie("tokenRh"),
					async: true,
					success: function(res) {

						$.ajax({
							type: "post",
							url: "http://47.104.13.109/applyfor-service/freeze/applyfor",
							async: true,
							data: {
								applyforUser: res.id,
								userName: res.loginName,
								userRole: res.roleList["0"].id,
								buapSpare1: $("#buapSpare1").val(),
							},
							success: function(data) {
								alert(data.message);
								console.log($("#buapSpare1").val());
								window.location.href = "javascript:history.go(0)";
							}
						});
					}
				});
			})

		})
	</script>

</html>